package com.haiyi.software.app;

import android.R.anim;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class ActivityModifyJob extends Activity {

	private Button btn_saveback;

	private String job;

	private TextView textView_job;

	private ListView list_alljobs;

	private String[] jobs = new String[] { "计算机/互联网/通信", "生产/工艺/制造",
			"商业/服务业/个体经营", "金融/银行/投资/保险", "文化/广告/传媒", "娱乐/艺术/表演", "医疗/护理/制药",
			"律师/法务", "教育/培训" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO 自动生成的方法存根
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_modify_job);

		getParameters();

		initComp();

		initData();
	}

	private void initData() {
		// TODO 自动生成的方法存根
		this.textView_job.setText(this.job);

		this.list_alljobs.setAdapter(new ArrayAdapter<String>(
				ActivityModifyJob.this, R.layout.item_job, jobs));
	}

	private void initComp() {
		// TODO 自动生成的方法存根
		this.btn_saveback = (Button) this.findViewById(R.id.btn_saveback);
		this.textView_job = (TextView) this.findViewById(R.id.textView_job);
		this.list_alljobs = (ListView) this.findViewById(R.id.list_alljobs);

		this.btn_saveback.setOnClickListener(saveClick);
		this.list_alljobs.setOnItemClickListener(itemClick);
	}

	private void getParameters() {
		// TODO 自动生成的方法存根
		this.job = this.getIntent().getStringExtra("job");
	}

	private OnItemClickListener itemClick = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			// TODO 自动生成的方法存根
			textView_job.setText(jobs[position]);
			job = jobs[position];
		}
	};

	private OnClickListener saveClick = new OnClickListener() {

		@Override
		public void onClick(View v) {

			Intent intent = new Intent();

			intent.putExtra("job", job);

			setResult(ActivityModifyInformation.SHOW_SUB_ACTIVITY_JOB, intent);

			ActivityModifyJob.this.finish();
		}
	};
}
